package com.qidian.tcba.admin.service.impl;


import com.qidian.tcba.admin.model.dto.user.UserAnnouncementsDTO;
import com.qidian.tcba.admin.model.entity.Announcement;
import com.qidian.tcba.admin.service.AnnouncementService;
import com.qidian.tcba.dao.AnnouncementMapper;
import com.qidian.tcba.utils.BeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 通知表 服务实现类
 * </p>
 *
 * @author 冯永龙
 * @since 2021-07-06
 */
@Service
public class AnnouncementServiceImpl implements AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;

    @Override
    public List<UserAnnouncementsDTO> getUserAnnouncements(int receiveId,int page,int size) {
        int index = (page - 1) * size;
        List<Announcement> announcements = announcementMapper.getAnnouncements(receiveId,index,size);
        return BeanMapper.mapList(announcements, UserAnnouncementsDTO.class);
    }
}
